<template>
  <!-- 左右环绕 card -->
  <div class="farmland">
    <div
      v-for="(item, index) in dataset"
      :key="index"
      class="farmland-item"
      :style="{ height: height + 'px', margin: margin }"
    >
      <div class="item-name colorWhite">
        {{ item.name }}
      </div>
      <div class="item-value colorYellow">
        {{ item.value }}
        <span v-if="isCounty">{{ unitCounty[item.name] || "亩" }}</span>
        <span v-else>{{ unit[item.name] || "万亩" }}</span>
      </div>
    </div>
  </div>
</template>

<script>
const unit = {
  理赔面积: '万亩',
  理赔次数: '万次',
  理赔总金额: '亿元',
  贴息总金额: '亿元',
  粮食总产量: '万吨',
  已发放总金额: '万元',
  补贴金额: '亿元',
  保险金额: '亿元',
  贷款金额: '亿元',
  已发放农户: '万户',
  亩均补贴金额: '元'
};
const unitCounty = {
  理赔面积: '亩',
  理赔次数: '万次',
  理赔总金额: '亿元',
  贴息总金额: '亿元',
  粮食总产量: '吨',
  已发放总金额: '万元',
  补贴金额: '万元',
  保险金额: '万元',
  贷款金额: '万元',
  已发放农户: '万户',
  亩均补贴金额: '元'
};

export default {
  props: {
    dataset: {
      type: Array,
      default: () => []
    },
    height: {
      type: String,
      default: '55'
    },
    margin: {
      type: String,
      default: '10px 30px'
    }
  },
  data () {
    return {
      unit,
      unitCounty
    };
  },
  computed: {
    isCounty () {
      return JSON.parse(this.$store.getters.areaIds).length === 3;
    }
  }
};
</script>

<style lang="less" scoped>
.farmland {
  margin-left: -5px;
  .farmland-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 17px;
    margin: 10px 30px;
    width: 412px;
    background: url(~@/assets/imgs/item-bg.webp) no-repeat;
  }
}
</style>
